package com.littlebee.storychild.common.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 19/1/2016.
 */
public class QueryParams {
    Map<String,String> params=new HashMap<String,String>();

    public QueryParams(){
    }

    public void setParam(String key, String value){
        params.put(key,value);
    }
    public void setParam(String key, int value){
        params.put(key, String.valueOf(value));
    }
    public void setParam(String key, double value){
        params.put(key, String.valueOf(value));
    }

    public String getParamsString(){
        StringBuilder sb=new StringBuilder();

        for (String key : params.keySet()) {
            if(sb.length()==0){
                sb.append("?"+key+"="+params.get(key));
            }
            else{
                sb.append("&"+key+"="+params.get(key));
            }
        }

        return sb.toString();
    }
}
